using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WPFServices.ViewModels.DomainViewModel.Material;

namespace WPFServices.Views.DomainViews.Material
{
    /// <summary>
    /// MaterialSelectionWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MaterialSelectionWindow : Window
    {
        public MaterialSelectionWindow()
        {
            InitializeComponent();
            var viewModel = new MaterialSelectionViewModel();
            this.DataContext = viewModel;

            // 订阅ViewModel的关闭窗口事件
            viewModel.CloseWindow += (result) =>
            {
                if (result != null)
                {
                    DialogResult = true;
                    SelectedItem = result;
                }
                else
                {
                    DialogResult = false;
                }
                Close();
            };
        }

        /// <summary>
        /// 选中的物料或产品
        /// </summary>
        public object SelectedItem { get; private set; }
    }
} 